<?php

namespace app\admin\model;

use think\Model;
use think\Db;

class ManageModel extends Model
{
  public function select($page){
    $total = Db::table('gjc_job')->count();//获取总的数量
    $pageSize = 5;//每页显示5个
    $res = Db::table('gjc_job')->limit($page,5)->select();//获取职位表
    return [
      $res,
      $total
    ];
  }

  public function getMenu(){//获取菜单
    return $res = Db::table('gjc_menu')->select();
  }
  public function onlyName($name){
    return $res = Db::table('gjc_job')->where('name',$name)->select();
  }
  public function addManage($name){
    $data = [
      'name'=>$name,
    ];
    return $res = Db::table('gjc_job')->insert($data);
  }
  public function changeManage($name,$xiaBiao){
    return $res = Db::table('gjc_job')->where('jid', $xiaBiao)->update(['name' => $name]);
  }
  public function del($jid){
    return Db::table('gjc_job')->where('jid',$jid)->delete();
  }
  public function getOfMenu($jid){
    return $res = Db::table('gjc_job')->where('jid',$jid)->find();
  }
  public function changeId($jid,$menu_id){
    return $res = Db::table('gjc_job')->where('jid',$jid)->update(['menu_id'=>$menu_id]);
  }
}